// 注册请求
class UserRegisterRequestEntity {
  String email;
  String password;

  UserRegisterRequestEntity({
    required this.email,
    required this.password,
  });

  factory UserRegisterRequestEntity.fromJson(Map<String, dynamic> json) =>
      UserRegisterRequestEntity(
        email: json["email"],
        password: json["password"],
      );

  Map<String, dynamic> toJson() => {
        "email": email,
        "password": password,
      };
}

// 登录请求
class UserLoginRequestEntity {
  String email;
  String password;

  UserLoginRequestEntity({
    required this.email,
    required this.password,
  });

  factory UserLoginRequestEntity.fromJson(Map<String, dynamic> json) =>
      UserLoginRequestEntity(
        email: json["email"],
        password: json["password"],
      );

  Map<String, dynamic> toJson() => {
        "email": email,
        "password": password,
      };
}

// 登录返回
class UserLoginResponseEntity {
  String? accessToken;
  String? displayName;
  List<String>? channels;

  UserLoginResponseEntity({
    this.accessToken,
    this.displayName,
    this.channels,
  });

  factory UserLoginResponseEntity.fromJson(Map<String, dynamic> json) =>
      UserLoginResponseEntity(
        accessToken: json["access_token"],
        displayName: json["display_name"],
        channels: List<String>.from(json["channels"].map((x) => x)),
      );

  Map<String, dynamic> toJson() => {
        "access_token": accessToken,
        "display_name": displayName,
        "channels":
            channels == null ? [] : List<dynamic>.from(channels!.map((x) => x)),
      };
}

class ErdsUserLoginInfo {
  String? avatarName;
  String? avatarUrl;
  String? createTime;
  Map? dept;
  int? deptId;
  String? email;
  bool? enabled;
  String? gender;
  bool? hasChildren;
  int? id;
  bool? isAdmin;
  List? jobs;
  String? label;
  bool? leaf;
  String? nickName;
  String? nodeId;
  String? phone;
  String? platformPermission;
  String? pwdResetTime;
  List? roles;
  String? salt;
  String? settings;
  String? updateBy;
  String? username;

  ErdsUserLoginInfo({
    this.avatarName,
    this.avatarUrl,
    this.createTime,
    this.dept,
    this.deptId,
    this.email,
    this.enabled,
    this.gender,
    this.hasChildren,
    this.id,
    this.isAdmin,
    this.jobs,
    this.label,
    this.leaf,
    this.nickName,
    this.nodeId,
    this.phone,
    this.platformPermission,
    this.pwdResetTime,
    this.roles,
    this.salt,
    this.settings,
    this.updateBy,
    this.username,
  });

  ErdsUserLoginInfo.fromJson(Map<String, dynamic> json) {
    avatarName = json['avatarName'];
    avatarUrl = json['avatarUrl'];
    createTime = json['createTime'];
    dept = json['dept'];
    deptId = json['deptId'];
    email = json['email'];
    enabled = json['enabled'];
    gender = json['gender'];
    hasChildren = json['hasChildren'];
    id = json['id'];
    isAdmin = json['isAdmin'];
    jobs = json['jobs'];
    label = json['label'];
    leaf = json['leaf'];
    nickName = json['nickName'];
    nodeId = json['nodeId'];
    phone = json['phone'];
    platformPermission = json['platformPermission'];
    pwdResetTime = json['pwdResetTime'];
    roles = json['roles'];
    salt = json['salt'];
    settings = json['settings'];
    updateBy = json['updateBy'];
    username = json['username'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['avatarName'] = avatarName;
    data['avatarUrl'] = avatarUrl;
    data['createTime'] = createTime;
    data['dept'] = dept;
    data['deptId'] = deptId;
    data['email'] = email;
    data['enabled'] = enabled;
    data['gender'] = gender;
    data['hasChildren'] = hasChildren;
    data['id'] = id;
    data['isAdmin'] = isAdmin;
    data['jobs'] = jobs;
    data['label'] = label;
    data['leaf'] = leaf;
    data['nickName'] = nickName;
    data['nodeId'] = nodeId;
    data['phone'] = phone;
    data['platformPermission'] = platformPermission;
    data['pwdResetTime'] = pwdResetTime;
    data['roles'] = roles;
    data['salt'] = salt;
    data['settings'] = settings;
    data['updateBy'] = updateBy;
    data['username'] = username;
    return data;
  }
}

/// 用户基本信息
class UserBaseInfo {
  String? avatarUrl; //头像地址
  String? jobId; //用户工号
  String? manuscriptsCollectionMonthlyAll; //月度稿件采集总量
  String? manuscriptsCollectionPercent; //月度稿件采集任务完成率
  String? manuscriptsCollectionAll; //稿件采集总量
  String? manuscriptsCollectionStandar; //月度稿件采集标准
  String? nickName; //用户昵称
  String? regionName; //旗区名称
  String? userId; //用户id
  String? userName; //用户名称
  String? userRole; //用户角色

  UserBaseInfo({
    this.avatarUrl,
    this.jobId,
    this.manuscriptsCollectionMonthlyAll,
    this.manuscriptsCollectionPercent,
    this.manuscriptsCollectionAll,
    this.manuscriptsCollectionStandar,
    this.nickName,
    this.regionName,
    this.userId,
    this.userName,
    this.userRole,
  });

  UserBaseInfo.fromJson(Map<String, dynamic> json) {
    avatarUrl = json['avatarUrl'];
    jobId = json['jobId'];
    manuscriptsCollectionMonthlyAll = json['manuscriptsCollectionMonthlyAll'];
    manuscriptsCollectionPercent = json['manuscriptsCollectionPercent'];
    manuscriptsCollectionAll = json['manuscriptsCollectionAll'];
    manuscriptsCollectionStandar = json['manuscriptsCollectionStandar'];
    nickName = json['nickName'];
    regionName = json['regionName'];
    userId = json['userId'];
    userName = json['userName'];
    userRole = json['userRole'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['avatarUrl'] = avatarUrl;
    data['jobId'] = jobId;
    data['manuscriptsCollectionMonthlyAll'] = manuscriptsCollectionMonthlyAll;
    data['manuscriptsCollectionPercent'] = manuscriptsCollectionPercent;
    data['manuscriptsCollectionAll'] = manuscriptsCollectionAll;
    data['manuscriptsCollectionStandar'] = manuscriptsCollectionStandar;
    data['nickName'] = nickName;
    data['regionName'] = regionName;
    data['userId'] = userId;
    data['userName'] = userName;
    data['userRole'] = userRole;
    return data;
  }
}
